﻿<script type="text/javascript">
	var columnVoice = {
	    _dataJson : "",
	    _column : "",
	    voiceInit : function(intent,column,dataJson){
	        columnVoice._dataJson = dataJson;
	        columnVoice._column = column;
	        var movieArray = {
	        	"id" : ["btn_yxsy","btn_4kdp","btn_hwdp","btn_hyjx","btn_dhzj","btn_jldy"],
	        	"name" : ["院线首映","4K大片","海外大片","华语精选","动画之家","纪录电影"]
	        }
	        var teleplayArray = {
	        	"id" : ["btn_zx","btn_nd","btn_dm","btn_hj","btn_tvb","btn_ymj"],
	        	"name" : ["最新","内地","动漫","亚洲","港台","英美剧"]
	        }

	        var Scene = {
	            "_scene": "com.iflytek.xiri.MyScene",
	            "_commands": {
	                "_PAGE": ["$P(_PAGE)"],
	                "order": ["订购"],
	                "collect": ["最近观看"],
	                "search": ["搜索"]
	            },
	            "_feedbacks": {
	            	"order": "进入订购",
	                "collect": "进入最近观看",
	                "search": "进入搜索"
	            }
	        }

	        if(column == "MOV"){
	            for(var i=0; i<movieArray.id.length; i++){
	                Scene._commands[movieArray.id[i]] = [movieArray.name[i]];
	                Scene._feedbacks[movieArray.id[i]] = movieArray.name[i]+"分类";
	            }
	        }else if(column == "TV"){
	        	for(var i=0; i<teleplayArray.id.length; i++){
	                Scene._commands[teleplayArray.id[i]] = [teleplayArray.name[i]];
	                Scene._feedbacks[teleplayArray.id[i]] = teleplayArray.name[i]+"分类";
	            }
	        }
	        if(dataJson != null && dataJson.vodName.length > 0){
	        	for(var i=0; i<dataJson.vodName.length; i++){
		            Scene._commands[i] = [dataJson.vodName[i]];
		            Scene._feedbacks[i] = "观看"+dataJson.vodName[i];
		        }
	        }
	        //for(var p in Scene._commands){
	        //	commonTools.debug(p+" | "+Scene._commands[p]);
		    //}
	        intent.regist(Scene);
	        intent.syncViewState("other");
	    },
	    voiceBack : function(intent){
	        var command = intent._command;
	        if(command.indexOf("PAGE") != -1){
	        	switch(intent._action){
		            case "PREV":
		                pagePre();
		                break;
		            case "NEXT":
		                pageNext();
		                break;
		        }
	        }else if(command == "order" || command == "collect" || command == "search"){
	        	switch(command){
		            case "order":
		                order('order');
		                break;
		            case "collect":
		                collect();
		                break;
		            case "search":
		                search();
		                break;
		        }
	        }else if(command.indexOf("btn_") != -1){
	            if(document.activeElement.id != command && document.getElementById(command)){
	                document.getElementById(command).focus();
	            }
	        }else{
	        	if(columnVoice._column == "MOV"){
	        		var _index = parseInt(command);
	        		if(columnVoice._dataJson.vodType[_index] == 5){
						triGo(columnVoice._dataJson.vodInfo[_index],columnVoice._dataJson.focusId[_index]);
	        		}else{
	        			urlGo(columnVoice._dataJson.vodInfo[_index],columnVoice._dataJson.focusId[_index]);
	        		}
	        	}else if(columnVoice._column == "TV"){
	        		var _index = parseInt(command);
	        		urlGo(columnVoice._dataJson.vodInfo[_index],columnVoice._dataJson.vodInfo[_index],columnVoice._dataJson.vodType[_index],columnVoice._dataJson.focusId[_index]);
	        	}
	        }
	    }
	}

	var movieInfoVoice = {
	    _dataJson : "",
	    _movieJson : "",
	    voiceInit : function(intent,movieJson,dataJson){
	    	movieInfoVoice._movieJson = movieJson;
	        movieInfoVoice._dataJson = dataJson;
	        var Scene = {
	            "_scene": "com.iflytek.xiri.MyScene",
	            "_commands": {
	                "_PLAY": ["$P(_PLAY)"],
	                "_PAGE": ["$P(_PAGE)"],
	                "order": ["订购"]
	            },
	            "_feedbacks": {
	            	"order": "进入订购"
	            }
	        }

	        if(movieJson.SD && movieJson.SD.预告片){
	        	Scene._commands["prevue"] = ["预告片"];
	            Scene._feedbacks["prevue"] = "播放预告片";
	        }else{
	        	if(movieJson['4K']){
	        		Scene._commands["4K"] = ["4K"];
	            	Scene._feedbacks["4K"] = "播放4K码率";
	        	}
	        	if(movieJson.HD){
	        		Scene._commands["HD"] = ["高清"];
	            	Scene._feedbacks["HD"] = "播放高清码率";
	        	}
	        	if(movieJson.SD){
	        		Scene._commands["SD"] = ["标清"];
	            	Scene._feedbacks["SD"] = "播放标清码率";
	        	}
	        }

	        if(dataJson != null && dataJson.length > 0){
	        	for(var i=0; i<dataJson.length; i++){
		            Scene._commands[i] = [dataJson[i].f_cc_name];
		            Scene._feedbacks[i] = "观看"+dataJson[i].f_cc_name;
		        }
	        }

	        intent.regist(Scene);
	        intent.syncViewState("other");
	    },
	    voiceBack : function(intent){
	        var command = intent._command;
	        if(command.indexOf("PAGE") != -1 || command.indexOf("PLAY") != -1){
	        	switch(intent._action){
		            case "PLAY":
	                    var playCode = "";
	                    var movieJSON = movieInfoVoice._movieJson;
		                if(movieJSON['4K']){
	                        playCode = movieJSON['4K'].DEFAULT[0].f_cc_code;
	                    }else if(movieJSON.HD){
	                        playCode = movieJSON.HD.DEFAULT[0].f_cc_code;
	                    }else if(movieJSON.SD){
	                        playCode = movieJSON.SD.DEFAULT[0].f_cc_code;
	                    }else if(movieJSON.SD && movieJson.SD.预告片){
	                        playCode = movieJSON.SD.预告片[0].f_cc_code;
	                    }
	                    playGo(playCode,"play1");
		                break;
	                case "PREV":
	                    pagePre();
	                    break;
		            case "NEXT":
		                pageNext();
		                break;
		        }
	        }else if(command == "order"){
	        	order('order');
	        }else if(command == "prevue" || command == "4K" || command == "HD" || command == "SD"){
	            var movieJSON = movieInfoVoice._movieJson;
	            var playCode = "";
	            switch(command){
		            case "prevue":
		                playCode = movieJSON.SD.预告片[0].f_cc_code;
		                break;
		            case "4K":
		            	playCode = movieJSON['4K'].DEFAULT[0].f_cc_code;
		                break;
		            case "HD":
		            	playCode = movieJSON.HD.DEFAULT[0].f_cc_code;
		                break;
		            case "SD":
		            	playCode = movieJSON.SD.DEFAULT[0].f_cc_code;
		                break;
		        }
	            playGo(playCode,"play1");
	        }else{
	    		var _index = parseInt(command);
	    		curlGo(movieInfoVoice._dataJson[_index].f_cc_multirateid);
	        }
	    }
	}

	var tvInfoVoice = {
	    _dataJson : "",
	    _seriesJSON : "",
	    _historyJSON : "",
	    _rates : "",
	    voiceInit : function(intent,rateFlag,rates,seriesJSON,historyJSON,dataJson){
	    	tvInfoVoice._rates = rates;
	    	tvInfoVoice._seriesJSON = seriesJSON;
	    	tvInfoVoice._historyJSON = historyJSON;
	        tvInfoVoice._dataJson = dataJson;

	        var Scene = {
	            "_scene": "com.iflytek.xiri.MyScene",
	            "_commands": {
	                "_PLAY": ["$P(_PLAY)"],
	                "_PAGE": ["$P(_PAGE)"],
	                "_EPISODE ": ["$P(_EPISODE)"],
	                "order": ["订购"]
	            },
	            "_feedbacks": {
	            	"order": "进入订购"
	            }
	        }

	        if(rateFlag){
	        	//if(rates == "hd"){
					Scene._commands["rateFlag"] = ["标清"];
				//}else if(rates == "sd"){
					Scene._commands["rateFlag1"] = ["高清"];
				//}
                Scene._feedbacks["rateFlag"] = "标清切换";
	            Scene._feedbacks["rateFlag1"] = "高清切换";
	        }

			if(dataJson != null && dataJson.length > 0){
	        	for(var i=0; i<dataJson.length; i++){
		            Scene._commands["mov_"+i] = [dataJson[i].f_cc_name];
		            Scene._feedbacks["mov_"+i] = "观看"+dataJson[i].f_cc_name;
		        }
	        }

	        intent.regist(Scene);
	        intent.syncViewState("other");
	    },
	    voiceBack : function(intent){
	        var command = intent._command;
	        if(command.indexOf("PLAY") != -1 || command.indexOf("PAGE") != -1 || command.indexOf("EPISODE") != -1){
	        	switch(intent._action){
		            case "PLAY":
	                    var rates = tvInfoVoice._rates;
	                    var historyJSON = tvInfoVoice._historyJSON;
	                    var seriesJSON = tvInfoVoice._seriesJSON;

	                    if(historyJSON == "" || historyJSON.f_uvh_seriesid == "0" || historyJSON.f_uvh_seriesid == 0){
	                        bookmarkUrl(1);
	                    }else{
	                        var historycount = parseInt(historyJSON.f_uvh_seriesid);
	                        if(rates == "hd"){
	                            if(historycount > seriesJSON.HD.DEFAULT.length){
	                                historycount = seriesJSON.HD.DEFAULT.length;
	                            }
	                        }else if(rates == "sd"){
	                            if(historycount > seriesJSON.SD.DEFAULT.length){
	                                historycount = seriesJSON.SD.DEFAULT.length;
	                            }
	                        }
	                        bookmarkUrl(historycount);
	                    }
		                break;
	                case "PREV":
	                    pagePre();
	                    break;
		            case "NEXT":
		                pageNext();
		                break;
		            case "INDEX":
		            	var json = "";
		            	var rates = tvInfoVoice._rates;
		            	var seriesJSON = tvInfoVoice._seriesJSON;
		            	var playType = false;
				        if(rates == "hd"){
							json = seriesJSON.HD.DEFAULT;
						}else if(rates == "sd"){
							json = seriesJSON.SD.DEFAULT;
						}
						for(var i=0; i<json.length; i++){
							if(intent.index == json[i].f_cc_viewindex && json[i].f_cc_type == 1){
								playType = true;
								break;
							}
						}
						if(playType){
							urlGo('history_url',intent.index);
						}
		                break;
		        }
	        }else if(command == "order"){
	        	order('order');
	        }else if(command == "rateFlag" && tvInfoVoice._rates == "hd" ){
	        	change();
	        }else if(command == "rateFlag1" && tvInfoVoice._rates == "sd" ){
                change();
            }else if(command.indexOf("mov_") != -1){
	        	var recJSON = tvInfoVoice._dataJson;
	            var _index = parseInt(command.substring(command.length-1,command.length));
	            refreshContent(recJSON[_index].f_cc_multirateid,command);
	        }
	    }
	}
</script>